Native sent every answer uncompressed and advertised response_compression: [].
PHP Server gzip- or deflate-encodes JSON answers of 1024 bytes or more when
Accept-Encoding allows it (DW_COMPRESSION_ENABLED, default true).
On a Dev cell behind a Cloudflare tunnel the origin answers are the cell's
egress, which is shaped to 4 Mbit/s. The Cloudflare edge always asks the
origin for "br, gzip" and decodes for clients that did not ask, so this
reduces tunnel egress without any SDK change. Lab measurement (DW Standard
Workflow v1, 1 wf/s, 4 workers): 384.8 KB -> 106.0 KB of origin response
bytes per workflow.
- New response_compression middleware, outermost on the router: PHP's
encoding preference (gzip over deflate at equal q, *, q=0), JSON content
types only, 1024-byte minimum, existing Content-Encoding left alone,
Vary: Accept-Encoding. Only in-memory (exact-sized) bodies are encoded;
streamed answers pass through.
- DW_COMPRESSION_ENABLED (and its legacy name) is honored instead of ignored.
- cluster info advertises ["gzip", "deflate"] when enabled, as PHP does; the
native deviation is removed from the parity fixture.
- History-page gzip reuses the same RFC 1952 encoder.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Why
The Cloud Dev benchmark on native 3.15.0 was capped at 1.5 wf/s by the cell's 4 Mbit/s egress shaper, not by CPU. One cause is that native sends every answer uncompressed and advertises
response_compression: []. PHP Server, by contrast, gzip- or deflate-encodes JSON answers of 1024 bytes or more (CompressResponse,DW_COMPRESSION_ENABLED, default true).In a Dev cell the origin answers are the cell's egress: the Cloudflare tunnel carries them as the origin produced them, and cloudflared has no compression option. The Cloudflare edge always asks the origin for
accept-encoding: br, gzipand decompresses for clients that didn't ask (Cloudflare docs). So this change reduces tunnel egress for every existing SDK, with no client or Cloud change.What
response_compression, the outermost layer on the router. It follows PHP'sCompressResponse:*as both, and treatsq=0as refused.deflateis the zlib format (RFC 1950) that HTTP'sdeflatecoding names, not raw DEFLATE.Content-Encodingalone and addsVary: Accept-Encoding.spawn_blocking). At roughly 30 MB/s for level 6, an 8 MB body would otherwise hold one of the runtime's async workers for about 300 ms.DW_COMPRESSION_ENABLED(and the legacyWORKFLOW_SERVER_COMPRESSION_ENABLED) is nowHonored; it wasIgnoredbefore.["gzip","deflate"]when compression is enabled, as PHP does. The native deviation is removed fromtests/Fixtures/ServerParity/cluster-capabilities.json.Measured (lab)
Setup
mainwith this change, in a 1 vCPU / 1 GiB slice that mimics a Dev cell: MySQL 8.0.46, the same limits asdocker-compose.vultr-dev-runtime-native.yml.br, gziplike the Cloudflare edge, and logs the origin bytes for each request ($upstream_bytes_received).main(same as published 3.15.0: 386 KB)main+ this PRCPU (lab slice, 1 vCPU, including MySQL):
main90%; this PR with Native: opt-in capabilities digest instead of ~17 KB server_capabilities on every worker answer #1262 and the SDK change 92%. Compression is not free, but encoding the much smaller bodies roughly offsets it.encode_costtest prints this by size.The remaining bytes are mostly the ~17 KB
server_capabilitiesobject repeated in every worker answer (5.6 KB each after gzip). The companion PR (opt-in capabilities digest) removes those copies. With both PRs and the matching SDK change, the same run measured 18.4 KB/workflow.Tests
response_compression):deflateround trip with header checks.encode_costbenchmark.tests/Unit/ServerParityClusterCapabilitiesContractTest.mjs. Native advertising no compression is now rejected.cargo test --lib -- response_compression cluster_info config_audit history_pages: all passed (see the latest comment for counts).cargo test --test execution -- activity_results: 5 passed.node --test tests/Unit/ServerParityClusterCapabilitiesContractTest.mjs: 24 passed.Cloud. Nothing to change:
DW_COMPRESSION_ENABLEDdefaults to true and is already a known name for the strict env audit. Dev cells pick this up when they move to a Server release that contains it.🤖 Generated with Claude Code